package com.lw.smartdevice.dto;

import com.lw.smartdevice.exceptions.MyErrorCode;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/3/17 14:05
 */
public class R {
    private int code;
    private String msg;
    private Object data;

    public static R setOK(){
        return setOK(null);
    }

    public static R setOK(Object data){
        return getR(MyErrorCode.SUCCESS,"成功",data);
    }

    public static R setError(){
        return setError(null);
    }

    public static R setError(Object data){
        return getR(MyErrorCode.FAIL,"失败",data);
    }

    public static R getR(int code,String msg,Object data){
        R r=new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
